import urllib.request as request
import urllib
from urllib.request import Request,urlopen
import re

"""
 需要登录验证-暂留（09-21）
"""
keyname="休闲鞋"
keyname=urllib.request.quote(keyname)

for i in range(1,2):
   # url = "https://s.taobao.com/search?" \
   #       "spm=a21bo.21814703.201867-links-3.34.5af911d9LBbKLE&q="+\
   #       keyname+"&bcoffset=1&ntoffset=1&p4ppushleft=2%2C48&s="+str(i*44)
   url="https://s.taobao.com/search?spm=a21bo.21814703.201867-links-3.34.5af911d9NlXnLz&q=%E4%BC%91%E9%97%B2%E9%9E%8B&bcoffset=1&ntoffset=1&p4ppushleft=2%2C48&s=44"
   headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0"}  # 以火狐浏览器方式爬取
   url_firefox=Request(url,headers=headers)
   data=urlopen(url_firefox).read().decode("utf-8","ignore")
   print(f"{keyname}:\n{data} 第{i}此爬取成功")
